home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16339 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  927 b 

  1. Path: HOPPER.ACM.ORG!news
  2. From: varnk@e62.diebold.com (Ken Varn)
  3. Newsgroups: comp.lang.c++
  4. Subject: C++ beginner quesion on data member access.
  5. Date: 10 Apr 1996 12:57:10 GMT
  6. Organization: Diebold
  7. Message-ID: <4kgb76$r3s@HOPPER.ACM.ORG>
  8. NNTP-Posting-Host: 199.218.232.47
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13.  
  14.      I have been struggling with the proper way to declare and access data 
  15. members in my classes.  I was once told that a class should not allow any 
  16. data members to be public and that they should only be accessed via member 
  17. functions.  Why?  I know the reasons for declaring private data, but what do 
  18. I gain if all I am doing is providing a member function to get the private 
  19. data or set the private data.  i.e. why call a getData() function that 
  20. basically just returns the private data member as opposed to just declaring 
  21. the pviate data member as public.
  22.  
  23.  
  24.